<?php
//file application/service/User.php
namespace service;

use Dao\TestDao;

use Teemo\Core\Singleton;

use Teemo\Pool\Context;

class TestService
{
    use Singleton;

    /**
     * @param $address_id
     *
     * @return mixed
     * @desc 通过pk查询信息
     */
    public function getInfoByPk($address_id)
    {
        return TestDao::getInstance()->fetchByPk($address_id);
    }

    /**
     * @return mixed
     * @desc 获取所有列表
     */
    public function getList()
    {
        return TestDao::getInstance()->fetchAll();
    }

    /**
     * @param array $array
     *
     * @return bool
     * @desc 添加一个
     */
    public function add(array $array)
    {
        return TestDao::getInstance()->add($array);
    }

    /**
     * @param array $array
     * @param       $address_id
     *
     * @return bool
     * @throws \Exception
     * @desc 按id更新
     */
    public function updateById(array $array, $address_id)
    {
        return TestDao::getInstance()->update($array, "address_id={$address_id}");
    }

    /**
     * @param $address_id
     *
     * @return mixed
     * @throws \Exception
     * @desc 按id删除
     */
    public function deleteById($address_id)
    {
        return TestDao::getInstance()->delete("address_id={$address_id}");
    }
}